package edu.uwlax.cs.oayonlinestore.client.gui;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Widget;

import edu.uwlax.cs.oayonlinestore.client.OnlinestoreRService;
import edu.uwlax.cs.oayonlinestore.client.utils.TitlePage;

public class PageTest extends TitlePage {

	protected void create() {
		setTitle("Stuff that is usefull for testing");
		setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		add(new Button("Generate Test Data", new ClickListener() {
			public void onClick(Widget arg0) {
				OnlinestoreRService.Util.getInstance().generateTestData(
						new AsyncCallback() {
							public void onFailure(Throwable arg0) {
								if (arg0 instanceof NullPointerException)
									Window.alert(arg0.getMessage());
								throw new RuntimeException(arg0);

							}

							public void onSuccess(Object arg0) {
								Window.alert("Testdata generated successfully");
							}
						});
			}
		}));
	}

	public String getID() {
		return "Test";
	}

}
